package fy.uap.operatorImpl;

import java.util.ArrayList;
import java.util.List;

import fy.uap.bean.ApptitudeBean;
import fy.util.MyUtil;


public class ApptitudeReader {

	private List<String> aptitudeClass = new ArrayList<String>();
	private List<String> startTime = new ArrayList<String>();// : "my:开始时间",
	private List<String> endTime = new ArrayList<String>(); // : "my:到期时间",
	private List<String> inspection = new ArrayList<String>(); // : "my:是否年检",
	private List<String> record = new ArrayList<String>();// : "my:资质复审依据及记录",
	private List<String> remark = new ArrayList<String>(); // : "my:备注"

	public void read(String name, String value) {
		if ("资质类别PK".equals(name)) {
			aptitudeClass.add(MyUtil.replaceXMLString(value));
		} else if ("开始时间".equals(name)) {
			startTime.add(MyUtil.getDate(value));
		} else if ("到期时间".equals(name)) {
			endTime.add(MyUtil.getDate(value));
		} else if ("是否年检".equals(name)) {
			inspection.add(value);
		} else if ("资质复审依据及记录".equals(name)) {
			record.add(MyUtil.replaceXMLString(value));
		} else if ("备注".equals(name)) {
			remark.add(MyUtil.replaceXMLString(value));
		}
	}

	public List<ApptitudeBean> getApptitude() {
		List<ApptitudeBean> beans = null;
		if (aptitudeClass.size() > 0) {
			for (int i = 0, size = aptitudeClass.size(); i < size; i++) {
				ApptitudeBean bean = new ApptitudeBean();
				bean.setAptitudeClass(aptitudeClass.get(i));
				bean.setStartTime(startTime.get(i));
				bean.setEndTime(endTime.get(i));
				if (inspection.size() > 0 && record.size() > 0) {
					bean.setInspection(inspection.get(i));
					bean.setRecord(record.get(i));
					bean.setRemark(remark.get(i));
				}
				
				if(beans == null){
					beans = new ArrayList<ApptitudeBean>();
				}
				beans.add(bean);
			}
		}
		return beans;
	}
}
